﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Database;
using Business.Utilities;
using Business.ConnectDatabase;
using System.Threading;

namespace myWallet
{
    public partial class Register1 : App_Code.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            tblAccount obj = new tblAccount();
            obj.Email = txtEmail.Text.Trim();
            obj.Password = MD5.EncPwd(txtPassword.Text.Trim());
            obj.Phone = "";
            obj.Name = txtName.Text.Trim();
            //obj.Birthday
            obj.Gender = true;
            obj.Address = "";
            //obj.CountryId
            obj.CreatedDate = DateTime.Now;
            obj.CreatedBy = 0;
            obj.Active = true;
            obj.Visible = true;
            int id = new AccountDB().Insert(obj);
            if (id > 0)
            {
                Session["UserId"] = id.ToString();
                Response.Redirect("Default.aspx", false);
            }
            else if (id == 0)
            {
                pnMessage.InnerHtml = GetGlobalResourceObject("Common", "ThisEmailRegistered").ToString();
                pnMessage.Visible = true;
            }
            else
            {

                pnMessage.InnerHtml = GetGlobalResourceObject("Common", "RegisterFailed").ToString();
                pnMessage.Visible = true;
            }
        }
    }
}